#pragma once
#include <vector>
//#include "cBlockList.h"

struct sBlock {
	Str caption;
	Color color;
	Int begin;
	Int end;
};

struct sLine {
	Str caption;
	Color color;
	Str content;
	std::vector<sBlock> blocks;
	void updateContent(Str cnt);
};


class cEditor {
private:
	GuiObjs	obj;
	Window * globalEditor;
	Window * measureEditor;
	TextLine * divisionText;
	TextLine * divisionSteps;
	TextLine * bpmText;
	Button * advancedButton;
	TextLine * captionText;
	TextLine * offsetText;

	Button * loadButton;
	Button * saveButton;
	Button * newButton;
	WindowIO fileWindow;
	static void loadData(CChar *name, Ptr user);
	static void saveData(CChar *name, Ptr user);
	

	//advanced measure structures
	TextLine * structText;
	Button * structCancel;
	Button * structOk;

	// line checkboxes
	CheckBox * ch[10];

	static void divisionTextChanged(Ptr);
	static void divisionStepsChanged(Ptr);
	static void bpmTextChanged(Ptr);
	static void advancedButtonClicked(Ptr);
	static void captionTextChanged(Ptr);

	// advanced measure structures
	static void structTextChanged(Ptr);
	static void structCancelClicked(Ptr);
	static void structOkClicked(Ptr);
	static void ch1Clicked(Ptr);
	static void ch2Clicked(Ptr);
	static void ch3Clicked(Ptr);
	static void ch4Clicked(Ptr);
	static void ch5Clicked(Ptr);
	static void ch6Clicked(Ptr);
	static void ch7Clicked(Ptr);
	static void ch8Clicked(Ptr);
	static void ch9Clicked(Ptr);
	static void ch10Clicked(Ptr);
	
	void chToggle(int nr);

	// color
	static void globalColorButtonClicked(Ptr);
	static void offsetTextChanged(Ptr);

	static void newButtonClicked(Ptr);
	static void saveButtonClicked(Ptr);
	static void loadButtonClicked(Ptr);
	void resetValues();
	void updateGuiValues();

	// text for content
	TextLine * lineText;
	static void lineTextChanged(Ptr);
	//Region * editRegion;
	//cBlockList blockList;


public:
	void create();
	Int division;
	Int steps;
	Int bpm;
	Bool advancedBpm;
	std::vector<Int> bpmLogic;
	Int offset;

	// lines
	Int activeLine;
	void setActiveLine(Int line);
	void resetLines();
	std::vector<sLine> lines;

	// color
	ColorPicker colorPicker;
	Button * globalColorButton;
	Bool colorToGlobal;

	// for file saving
	Bool makeScreenshot;
	Str imageName;
};

extern cEditor editor;
extern Color background;